package com.huanletao.tran;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;

//@Component
public class UserService2 {

    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    PlatformTransactionManager transactionManager;

    /**
     * 声明事务；
     */
    @Transactional
    public void transfer4() {
      jdbcTemplate.update("update user set mony = ? where username=?", 999, "zhangsan");
    }
}
